﻿using System.Web.Security;
using Lapkin.Models.Repositories;

namespace Lapkin.Authenticate
{
    public class SiteRoleProvider : RoleProvider
    {
        private readonly SqlRepository _repository = new SqlRepository();

        public override bool IsUserInRole(string username, string roleName)
        {
            return _repository.AccountRepository.IsUserInRole(username, roleName);
        }

        public override string[] GetRolesForUser(string username)
        {
            return _repository.AccountRepository.GetRolesForUser(username);
        }

        public override void CreateRole(string roleName)
        {
            
        }

        public override bool DeleteRole(string roleName, bool throwOnPopulatedRole)
        {
            return false;
        }

        public override bool RoleExists(string roleName)
        {
            return false;
        }

        public override void AddUsersToRoles(string[] usernames, string[] roleNames)
        {
            
        }

        public override void RemoveUsersFromRoles(string[] usernames, string[] roleNames)
        {
            
        }

        public override string[] GetUsersInRole(string roleName)
        {
            return _repository.AccountRepository.FindUsersInRole(roleName);
        }

        public override string[] GetAllRoles()
        {
            return new string[0];
        }

        public override string[] FindUsersInRole(string roleName, string usernameToMatch)
        {
            return _repository.AccountRepository.FindUsersInRole(roleName);
        }

        public override string ApplicationName { get; set; }
    }
}